Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-yaml

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-yaml

Parse and stringify YAML code blocks in remark

  • 2.0.1
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

remark-yaml Build Status Coverage Status

Parse and stringify YAML code blocks in remark.

Supports IE9+ (mdn, Kangax).

Installation

npm

npm install remark-yaml

remark-yaml is also available for duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Table of Contents

Usage

var yaml = require('remark-yaml');
var remark = require('remark').use(yaml);
var input = [
    '---',
    '"layout": "post"',
    '"title": \'Blogging Like a Hacker\'',
    '---',
    '',
    '# A header!',
    ''
].join('\n');
var tree = remark.parse(input);

The yaml node now has a yaml property.

var data = tree.children[0].yaml;
{
  "layout": "post",
  "title": "Blogging Like a Hacker"
}

Stringifying the document (note the formatting) yields:

var doc = remark.stringify(tree);
---
layout: post
title: Blogging Like a Hacker
---

# A header!

API

remark.use(yaml, options)

Adds a yaml property to YAML nodes.

Signatures

  • remark = remark.use(yaml, options?).

Parameters

  • yaml — This plugin;

  • options (Object?) — Settings:

    • library (string? or Object?, default: nodeca/js-yaml) — you can also pass a file or node module in;

    • parse (string?, default "safeLoad");

    • stringify (string?, default "safeDump");

    • prettify (boolean?, default: true) — When true, the node’s content will be overwritten by the result of library[stringify](node.yaml);

    • onparse (function(Node), default function () {}) — Invoked when YAML is parsed, during parsing;

    • onstringify (function(Node), default function () {}) — Invoked when YAML is stringified, during stringification.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 26 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc